<extend name="Public/base" />
<block name="content">
    <center>
        <table style="margin-top:5%">
            <theat>
                <th style="width:6rem">学生姓名</th>
                <volist name="roleName" id="rn">
                    <th style="width:3rem"><abbr title="<{$rn.desc}>"><{$rn.role_name}></abbr></th>
                </volist>
                <th style="width:6rem">操作</th>
            </theat>
            <tbody>
                <volist name="stu" id="stu">
                   <tr class="c_<{$stu.student_id}>">
                        <td><{$stu.sname}></td>
                       <volist name="stu.rp" id="rp">
                           <td>
                               <{$rp}>
                           </td>
                       </volist>

                       <td>
                           <buttom class="button tiny radius bcs" onclick="bc(<{$stu.student_id}>)">保存</buttom>
                       </td>
                   </tr>
                </volist>
            </tbody>
        </table>
    </center>
    <script>
        function minus(a) {
            var num=$('.b_'+a).text();
            num=parseInt(num);
            if(num>0){
                num=num-1;
            }
            $('.b_'+a).html(num);
        }
        function plus(a) {
            var num=$('.b_'+a).text();
            num=parseInt(num)+1;
            $('.b_'+a).html(num);
        }
        function bc(a){
           var c='<{$rN}>';
            var pid='';
            var pfr='';
            c=c.split(',');
                for(i in c){
                    var d=$('.b_'+a+'_'+c[i]).text();
                    if(d!='0'){
                        pid+=c[i]+',';
                        pfr+=d+',';
                    }
                }
                pid=pid.substring(0,pid.length-1);
            pfr=pfr.substring(0,pfr.length-1);
            var data={
                student_id:a,
                points_roles_id:pid,
                points_frequency:pfr,
            };
            $.post("<{:U('save')}>",data,function(data){
                alert(data);
            });
        }

    </script>
</block>